package org.jeecg.common.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: minio上传辅助
 * @author: zwf
 * @create: 2025-05-12 13:59
 **/
public class ContentTypeUtils {

    private static final Map<String, String> EXTENSION_TO_CONTENT_TYPE = new HashMap<>();

    static {
        EXTENSION_TO_CONTENT_TYPE.put("jpg", "image/jpeg");
        EXTENSION_TO_CONTENT_TYPE.put("jpeg", "image/jpeg");
        EXTENSION_TO_CONTENT_TYPE.put("png", "image/png");
        EXTENSION_TO_CONTENT_TYPE.put("gif", "image/gif");
        EXTENSION_TO_CONTENT_TYPE.put("pdf", "application/pdf");
        EXTENSION_TO_CONTENT_TYPE.put("html", "text/html");
        EXTENSION_TO_CONTENT_TYPE.put("txt", "text/plain");
        EXTENSION_TO_CONTENT_TYPE.put("json", "application/json");
        EXTENSION_TO_CONTENT_TYPE.put("csv", "text/csv");
        EXTENSION_TO_CONTENT_TYPE.put("mp4", "video/mp4");
        EXTENSION_TO_CONTENT_TYPE.put("mp3", "audio/mp3");
        // 你可以继续添加更多的扩展名和 MIME 类型
    }

    public static String getContentType(String extension) {
        return EXTENSION_TO_CONTENT_TYPE.getOrDefault(extension, "application/octet-stream"); // 默认类型
    }
}
